<!-- prettier-ignore -->
<template>
  <div class="rule-manage">
    <el-row :gutter="16" style="margin-top: 10px" type="flex">
      <el-col :span="6">
        <el-button icon="el-icon-plus" size="small" type="primary">新建分组</el-button>
        <el-button icon="el-icon-plus" size="small" type="primary">新建</el-button>
        <el-button icon="el-icon-delete" size="small" type="primary">删除</el-button>
        <div style="border:1px solid #eee;margin-top:10px;height: calc(100% - 41px)">
          <el-tree :data="treeData" default-expand-all>
          </el-tree>
        </div>
      </el-col>
      <el-col :span="18">
        <el-table :data="tableData[0].children" :max-height="720" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" border default-expand-all header-row-class-name="table-header" row-key="id"  stripe>
          <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
          <el-table-column label="规则名称" prop="label"></el-table-column>
          <el-table-column label="规则描述">
            <template slot-scope="{row}">
              <span style="white-space: pre-wrap;">
                {{row.describe}}
              </span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="状态" width="120">
            <template slot-scope="{row}">
              <div style="display: flex;align-items: center;justify-content: center">
                <el-switch
                  v-model="row.isUse"
                  disabled>
                </el-switch>
                <span>{{row.isUse?'开启':'禁用'}}</span>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" label="操作" width="200">
            <template slot-scope="{row}">
              <el-button icon="el-icon-edit" type="text">编辑</el-button>
              <el-button icon="el-icon-delete" style="color:red" type="text">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import rulesJson from '@/assets/rules.json'
export default {
  name: 'ruleManage',
  data(){
    return{
      treeData:[
        {
          label:'全部规则(17)',
          id:'0',
          children:[
            {
              label:'信息缺失或重复',
              children:[
                {
                  "label": "地址门牌号缺失检查",
                  "describe": "检查门牌号不能为空,且以号结尾",
                  "type": "信息缺失或重复",
                  "id": "1",
                  "isUse": true,
                  "children": []
                },
                {
                  "label": "地址房间号缺失检查",
                  "describe": "检查地址为户室数据时，户室不允许存在空值",
                  "type": "信息缺失或重复",
                  "id": "2",
                  "children": [],
                  "isUse": true
                },{
                  "label": "重复字段检查",
                  "describe": "检查字段不能有重复。\n1）统一地址名称和统一地址编码不能重复\n2）楼栋数据，实体码不能重复",
                  "type": "信息缺失或重复",
                  "id": "7",
                  "children": [],
                  "isUse": true
                },{
                  "label": "字段为空检查",
                  "describe": "检查字段是否为空。\n1）区划不能为空，不能有县市重复\n2）非村组数据，街路巷字段不能为空\n3）村组数据，村民小组和自然村字段不能都为空\n4）当数据为楼、单元、楼层、户室类型时，楼牌号不能有空值\n5）楼栋数据，单元、楼层、户室必须为空\n6）经纬度不能为空\n7）统一地址名称和统一识别代码不能为空",
                  "type": "信息缺失或重复",
                  "id": "12",
                  "children": [],
                  "isUse": true
                },{
                  "label": "区划名称拼接重复性检查",
                  "describe": "统一地址区划不能拼接重复。",
                  "type": "信息缺失或重复",
                  "id": "15",
                  "children": [],
                  "isUse": true
                },
              ]
            },
            {
              label:'信息一致性问题',
              children:[
                {
                  "label": "地址完整描述与分节一致性检查",
                  "describe": "检查地址全称与地址分节拼接后是否保持一致",
                  "type": "信息一致性问题",
                  "id": "3",
                  "children": [],
                  "isUse": true
                },
                {
                  "label": "管理库和检索库数据一致性检查",
                  "describe": "检查管理库和检索库中数据是否一致",
                  "type": "信息一致性问题",
                  "id": "4",
                  "children": [],
                  "isUse": true
                },{
                  "label": "地址单元地址节一致性检查",
                  "describe": "户室数据包含信息与其楼层信息不一致，如楼层信息为2，户室信息为301。",
                  "type": "信息一致性问题",
                  "id": "8",
                  "children": [],
                  "isUse": true
                },{
                  "label": "区划名称编码一致性检查",
                  "describe": "区划名称和区划编码与标准区划要保持一致。",
                  "type": "信息一致性问题",
                  "id": "14",
                  "children": [],
                  "isUse": true
                },{
                  "label": "逻辑一致性检查",
                  "describe": "根据质检数据类型，检查相应字段逻辑一致性。",
                  "type": "信息一致性问题",
                  "id": "16",
                  "children": [
                    {
                      "label": "楼栋地址",
                      "describe": "1）当数据为楼、单元、楼层、户室类型时，楼牌号不能有空值\n 2）楼栋数据，单元、楼层、户室必须为空",
                      "type": "信息一致性问题",
                      "id": "16-1",
                      "children": [],
                      "isUse": true
                    },
                    {
                      "label": "户室地址",
                      "describe": "1）存在户室地址，必须要有对应楼幢地址",
                      "type": "信息一致性问题",
                      "id": "16-2",
                      "children": [],
                      "isUse": true
                    },
                    {
                      "label": "非村组地址",
                      "describe": "1）非村组地址数据，jmxq应为小区数据\n 2）非村组数据，街路巷描述为“XX路”“XX街”“XX大道”“XX巷”\n 3）非村组数据，街路巷字段不能为空",
                      "type": "信息一致性问题",
                      "id": "16-3",
                      "children": [],
                      "isUse": true
                    },
                    {
                      "label": "村组地址",
                      "describe": "1）村组数据，村民小组和自然村字段不能都为空\n 2）村组数据时，村民小组和自然村字段不能一致\n 3）村组数据时，村民小组和自然村字段不能包含小区",
                      "type": "信息一致性问题",
                      "id": "16-4",
                      "children": [],
                      "isUse": true
                    }
                  ],
                  "isUse": true
                },
              ]
            },
            {
              label:'信息有效性问题',
              children:[
                {
                  "label": "地址节健康度分析检查",
                  "describe": "地址质检通过率。",
                  "type": "信息有效性问题",
                  "id": "5",
                  "children": [],
                  "isUse": true
                },{
                  "label": "地址质量问题检查",
                  "describe": "检查地址质量问题。\n1）判断地址来源是否超出值域,超出值域视为质量问题（公安 /民政/住建/自规/不动产/政法/社区网格/网格打点/综治房屋/问题地址）\n2）判断海拔是否为空,是,则为质量问题",
                  "type": "信息有效性问题",
                  "id": "17",
                  "children": [],
                  "isUse": true
                }
              ]
            },
            {
              label:'信息合规性问题',
              children: [
                {
                  "label": "无效字符检查",
                  "describe": "检查字段中是否存在无效字符\n1）户室字段不能包含特殊字符。",
                  "type": "信息合规性问题",
                  "id": "6",
                  "children": [],
                  "isUse": true
                },{
                  "label": "字典项合规检查",
                  "describe": "设置字段字典项，检查字段是否在字典值范围内。\n1）街路巷名称不能为全数字且不能带区划信息",
                  "type": "信息合规性问题",
                  "id": "9",
                  "children": [],
                  "isUse": true
                },{
                  "label": "地址编码合规性检查",
                  "describe": "检查地址编码是否符合编码规则。\n1）检查编码长度21位字符",
                  "type": "信息合规性问题",
                  "id": "10",
                  "children": [],
                  "isUse": true
                },{
                  "label": "经纬度信息合规性检查",
                  "describe": "检查同一楼栋户室经纬度保持一致。",
                  "type": "信息合规性问题",
                  "id": "11",
                  "children": [],
                  "isUse": true
                },{
                  "label": "字段正则表达式符合检查",
                  "describe": "检查字段是否符合设置的正则表达式。\n1）统一识别代码由4050开头，并且为21位\n2）乡镇街道级行政区应描述为“XX街道”“XX乡”“XX镇”\n3）社区的描述应为“XX社区”，行政村应描述为“XX村”\n4）门牌号字段中不能有“号里”，“里”，建议批量刷为\"-\"",
                  "type": "信息合规性问题",
                  "id": "13",
                  "children": [],
                  "isUse": true
                },
              ]
            }
          ]
        }
      ],
      tableData:[
        {
          label:'全部规则(17)',
          id:'0',
          children:[]
        }
      ]
    }
  },
  created(){
    this.tableData[0].children = rulesJson.qualityTest
  }
};
</script>

<style lang="less" scoped>
.rule-manage{
  width: 100%;
  height: 100%;
  .container{
    margin-top: 10px
  }
}
</style>